package system.org.databaseConnect;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;


import system.org.entity.Customer;
import system.org.entity.Employee;

public class ProcessDB {
	DB_connect DB;
	public int insertNewEmployee(Employee emp) throws SQLException
	{
		int res=0;
		DB = new DB_connect();
		Connection con = DB.DBconnect();
		String sql = "insert into employee  (FirstName,LastName,DOB,Address,PhoneNo,Email,UserName,PASSWORD) " +
				"values (?,?,?,?,?,?,?,?)";
		
		PreparedStatement pstm =  con.prepareStatement(sql);
		pstm.setString(1, emp.getFirstName());
		pstm.setString(2, emp.getLastName());
		pstm.setDate(3, (Date) emp.getDOB());
		pstm.setString(4, emp.getAddress());
		pstm.setString(5, emp.getPhoneNo());
		pstm.setString(6, emp.getEmail());
		pstm.setString(7, emp.getUsername());
		pstm.setString(8, emp.getPassword());
		res =pstm.executeUpdate();
		con.close();
		return res;
	}
	
	public int insertNewCustomer(Customer cus) throws SQLException
	{
		int res=0;
		DB = new DB_connect();
		Connection con = DB.DBconnect();
		String sql = "insert into employee  (FirstName,LastName,DOB,Address,PhoneNo,Email,UserName,PASSWORD) " +
				"values (?,?,?,?,?,?,?,?)";
		
		PreparedStatement pstm =  con.prepareStatement(sql);
		pstm.setString(1, cus.getFirstName());
		pstm.setString(2, cus.getLastName());
		pstm.setDate(3, (Date) cus.getDOB());
		pstm.setString(4, cus.getAddress());
		pstm.setString(5, cus.getPhoneNo());
		pstm.setString(6, cus.getEmail());
		pstm.setString(7, cus.getUsername());
		pstm.setString(8, cus.getPassword());
		res =pstm.executeUpdate();
		con.close();
		return res;
	}
	
	
}
